package com.butterknife;

import android.app.Activity;

import java.lang.reflect.Constructor;

/*
 * create by LorenzoGao
 * Emial:2508719070@qq.com
 * DATE: 2019/4/19
 * TIME: 20:52
 * describe:
 */
public class ButterKnife {


    public static Unbinder bind(Activity activity) {

        try {
            Class<? extends Unbinder> bindClassName = (Class<? extends Unbinder>) Class.forName(activity.getClass().getName() + "_ViewBinding");

            //构造函数
            Constructor<? extends Unbinder> declaredConstructor = bindClassName.getDeclaredConstructor(activity.getClass());
            Unbinder unbinder = declaredConstructor.newInstance(activity);

            return unbinder;
        } catch (Exception e) {
            e.printStackTrace();
        }


        return Unbinder.EMPTY;
    }


}
